--[[

Copyright (c) 2012-2013 Baby-Bus.com

http://www.babybus.com/superdo/

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

]]

--[[!--

场景层类，定义层相关操作方法及逻辑实现。

-   定义场景层功能方法。

]]

----------------------
-- 类
----------------------
local M = classLayerTouch("Main")
M.TAG   = "Main"


----------------------
-- 公共参数
----------------------
-- [常量]
-- ..

-- [操作变量]
-- ..








----------------------
-- 构造方法
----------------------
--[[--

构造方法，定义视图实例初始化逻辑

### Parameters:
-   table **params**    参数集合

### Return: 
-   object              对象实例

]]
function M:ctor(params)
    -- [超类调用]
    M.super.ctor(self, params)

    -- [本类调用]
    -- 开屏图片是否下载
    self._isLogoDownload = false
    -- 开屏精灵
    self._startScreennode= nil
end








----------------------
-- 结点渲染
----------------------
--[[--

视图渲染，处理视图结点加载、事件绑定等相关操作

]]
function M:onRender()
    -- [超类调用]
    M.super.onRender(self)
    -- [本类调用]
    -- 发送友盟
    -- 加载背景
    self:loadBackground()
    -- 加载视频
    self:loadVideo()
end

-- 加载背景
function M:loadBackground()
    self._background = U.loadLayer({ color = COLOR4_WHITE }):p(0, 0):to(self)
    self._background._colorNode:setContentSize(V.fullSize.width,V.fullSize.height)

end

-- 加载视频
function M:loadVideo()
    -- 视频路径 
    local path = self:getVideoPath()

    -- 公共统计-开场视频播放次数   
    if isZhLanguage() then
    else
        DA.sendEvent(public_inter_startup_video_times,DA.getLanguageType())
    end

    ST.setString("PLAY_BOXVIDEO_END","0")
    A.cycle({
        {"delay",0.1},
        {"fn",function ( ... )
            local status = ST.getString("PLAY_BOXVIDEO_END")
            if status == "1" or ismac() then
                self:stopAllActions()
                self:switchNextScene()
                self:loadMainUI()
            end
        end}
    }):at(self)

    NV.playBoxMovie(path)

end

-- Add By SD.Mount 20151020
-- 跳到下一个场景
function M:switchNextScene()
    self:dispatchOnce(function()
        self:getScene():switchNextScene()
    end, self:getSwitchNextDelayTime())
end

-- Add By SD.Mount 20151020
-- 获取跳到下一个场景的延迟时间
function M:getSwitchNextDelayTime()
    -- 根据平台延迟时间判断
    -- 设置接收时间字段
    local delaytime = 0
        if isios() then
        if self:isWiFiAvailable() then
            delaytime = 2.5
        else
            delaytime = 0
        end
        elseif isandroid() then
        if self:isWiFiAvailable() then
            delaytime = 3.0
        else
            delaytime = 1.0
        end
    else
        if self:isWiFiAvailable() then
            delaytime = 5.0
        else
            delaytime = 0
        end
    end
    return delaytime
end

-- 加载主UI
function M:loadMainUI()
    local data = self:getRecommendImage()
    if istable(data) and data.adType == "thirdad" then
        NV.showOpenScreen({
            fnCallback = function ()
                D.getRunningScene():switchNextScene(false)
            end
        })
    else
        if CHANNEL_PLATFORM == CHANNEL_PR_BUBUGAO then
            PAY_FOR_NO_ADS = true
            D.img("g/pre_install/pr_bubugao.png"):p(481,270*Y_FACTOR+9):to(self,10000):scale(0.5)
            -- 版权信息
            self:loadCopyright()
        else
            -- Logo
            self:loadLogo()
            -- 版权信息
            self:loadCopyright()
            -- 全屏适配
            self:fullScreenAdaptation()
            -- 渠道
            self:loadChannel()
        end

    end
    
end

-- 加载Logo
function M:loadLogo()
    local data   = nil
    if not NT.isLocalWiFiAvailable() then
        data   = self:getRecommendImage()
        self:loadStartRecommend(data) 
    else
        try(function()
            if isios() then
                -- NV.requsetADByType(AD_KIND_OPEN)
                -- NV.requsetADByType(AD_KIND_INFIX)
                -- 开启定时器去轮询下载图片是否存在
                -- A.cycle({
                --     {"delay", 0.5},
                --     {"fn", function()
                --              local data2   = self:getRecommendImage()
                --              self:loadStartRecommend(data2)
                --     end}
                -- }):at(self:getParent())
                data   = self:getRecommendImage()
                self:loadStartRecommend(data)
            else 
                data   = self:getRecommendImage()
                self:loadStartRecommend(data) 
            end 
        end)
    end
end

-- 加载开屏宣传图
function M:loadStartRecommend(data)
    if not NT.isLocalWiFiAvailable() then
        self:getParent():stop()
    end
    -- if true then
    --     local path = "g/open/1.png"
    --     local node      = D.img(path):to(self)
    --     self._startScreennode = node

    --     self._adnode = D.imgsz("g/open/ad.png", CCSize(80*0.6*0.8,44*0.6*0.8)):p(0,0):anchor(ccp(1,0)):to(self,100)
    --     return
    -- end

    -- A004非中文简体开屏、巴士车、博士帽、家长中心关闭（左下角逻辑不变）
    local ctr1 = (BB_CHANNEL_ID == 'A004' or BB_CHANNEL_ID == 'A016' or BB_CHANNEL_ID == 'A022' or BB_CHANNEL_ID == 'A023') and device.language ~= "zh"
    -- 预装
    local ctr2 = CHANNEL_PLATFORM == CHANNEL_PR_HUAWEI or CHANNEL_PLATFORM == CHANNEL_PR_TANGMAO or CHANNEL_PLATFORM == CHANNEL_PR_HUOHUOTU 
    -- 开关关闭
    local ctr3 = not NV.getChannelConfig("startup_state") 
    if ctr1 or ctr2 or ctr3 then
        self:showCopyrightRecommend()
        return
    end
    
    local isDataError = (not data) or (not data.localImagePath) or (not IO.exists(data.localImagePath))
    if isDataError then 
        self:showCopyrightRecommend()
    else
        self:loadOpenRecommendImage(data)
    end
end

-- 展示版权
function M:showCopyrightRecommend()
    local data   = self:getRecommendImage()

    -- 竖屏修改
    local pos = ccp(480 * X_FACTOR, 320 * Y_FACTOR)
    if not isLanscape() then
        pos = ccp(270 * X_FACTOR, 480 * Y_FACTOR)
    end
    local imgName = "g/box/babybus_en.png"
    local ratio = 1
    if device.language == "zh" then
        imgName = "g/box/babybus_zh.png"
        ratio = 1.3
    end
    local node   = D.img(imgName):p(pos):to(self, 1000):scale(0.65*ratio)
    node.adType = "copyright"
    self._startScreennode = node

    -- 国内：无wifi、关闭自媒体开关、家庭专区、竖屏
    -- 国际化：无wifi、关闭自媒体开关、竖屏、无数据且默认图装完
    local str = "其他"
    if not NT.isLocalWiFiAvailable() then
        str = "无wifi"
    elseif not NV.getChannelConfig("startup_state") then
        str = "关闭自媒体开关"
    elseif (not data) or (not data.path) or (not IO.exists(data.path)) and not istable(self:isDefaultAppsInstalled()) then
        str = "无数据且默认图装完"
    end
    -- 公共统计-版权页曝光次数
    if isZhLanguage() then
        -- 非跳转渠道_WIFI、非跳转渠道_数据网络、非跳转渠道_无网络、跳转渠道_WIFI、跳转渠道_数据网络、跳转渠道_无网络    
        -- 无wifi、关闭自媒体开关、无数据且默认图装完
        local desc = "非跳转渠道"
        if NV.checkDownloadMarket() then
            desc = "跳转渠道"
        end
        desc = desc.."_"..DA.getInternetType()
        DA.sendEventWithMap(public_zh_startup_show_copyright_times,desc,str)
    else
        -- 公共统计-版权页曝光出现原因    
        DA.sendEvent(public_inter_show_copyright_reason,str)

        DA.sendEventWithMap(public_inter_startup_show_copyright_times,DA.getInternetType(),DA.getLanguageType())
    end
end



function M:isPublishKids()
    if box and isfunction(box.isPublishKids) then 
        return box.isPublishKids()
    else
        return false
    end
end


-- 开屏友盟发送 type: 曝光、点击
function M:sendUmengStartUp(data, umengType)
    if isZhLanguage() then
        local umengKey = public_zh_startup_click_times
        if umengType == "show" then
            umengKey = public_zh_startup_show_times
        end
        local desc2 = nil
        if NV.checkDownloadMarket() then
            if umengType == "show" then
                umengKey = public_zh_startup_market_show_times
            else
                umengKey = public_zh_startup_market_click_times
            end
        end
        -- 公共统计-开屏宣传图有效曝光次数(国内)
        if data.adType == "default" then
            if umengType == "show" then
                -- 黑名单展示写入
                NV.writeShowTime({
                    key = "selfad_1_"..data.ident,
                    updateTime = data.updateTime,
                    showNum = data.showNum
                })
                DA.sendEventAiolos(aiolos_startup_show_times,data.appKey)
            else
                -- 对矩阵自媒体功能留存和流量跟踪埋点方案
                DA.sendEventAiolos(aiolos_startup_click_times,data.appKey)
                local str = DA.getAppState(data.appKey)
                DA.sendEventAiolos(aiolos_startup_click_times_new,str)
            end
            DA.sendEventWithMap(umengKey,ifnil(desc2,"默认图"),data.adID)
        elseif data.adType == "selfad" then
            -- "1"            // 市场首发(独立开屏)
            -- "2"            // 通龄
            -- "3"            // 指定年龄
            if umengType == "show" then
                DA.sendEventAiolos(aiolos_startup_show_times,data.appKey)
            else
                -- 对矩阵自媒体功能留存和流量跟踪埋点方案
                DA.sendEventAiolos(aiolos_startup_click_times,data.appKey)
                local str = DA.getAppState(data.appKey)
                DA.sendEventAiolos(aiolos_startup_click_times_new,str)
            end

            if data.mediaType == "1" then
                DA.sendEventWithMap(umengKey,ifnil(desc2,"独立开屏"),data.adID)
            elseif data.mediaType == "2" then
                DA.sendEventWithMap(umengKey,ifnil(desc2,"通龄"),data.adID)
                if umengType == "show" then
                    DA.sendCommonShowUMeng(data.adID,1)
                end
                if umengType == "show" then
                    -- 黑名单展示写入
                    NV.writeShowTime({
                        key = "selfad_1_"..data.ident,
                        updateTime = data.updateTime,
                        showNum = data.showNum
                    })
                end
            elseif data.mediaType == "3" then
                local age = tonumber(data.mediaAge)
                if age<2 then
                    age = "mediaage_"..age
                elseif age > 5 then
                    age = "5+岁"
                else
                    age = (age-1).."-"..age.."岁"
                end
                DA.sendEventWithMap(umengKey,ifnil(desc2,age),data.adID)
                if umengType == "show" then
                    -- 黑名单展示写入
                    NV.writeShowTime({
                        key = "selfad_1_"..data.ident,
                        updateTime = data.updateTime,
                        showNum = data.showNum
                    })
                end
            end
        elseif data.adType == "ad" then
            local mTable = {"直接下载","打开网页"}
            local desc = ifnil(mTable[tonumber(ifnil(data.openType,0))],"不操作")
            if umengType == "show" then
                -- 广告统计-广告开屏图曝光次数  
                DA.sendEventWithMap4Haozi(ad_startup_show_times,desc,data.adID)
            else
                DA.sendEventWithMap4Haozi(ad_startup_click_times,desc,data.adID)
                if click_url then
                    DA.sendEventSecond(click_url)
                end
            end
        elseif data.adType == "thirdad" then
            if umengType == "show" then
                for i,v in ipairs(data.pm) do
                    DA.sendEventSecond(v)
                end
                DA.sendEvent(thirdad_startup_show_times,"开屏")
                -- 广告统计-广告开屏图曝光次数  
                -- DA.sendEventWithMap(all_ad_startup_show_times,"第三方广告",data.adID)
                DA.sendEventWithMap4Haozi(all_ad_startup_show_times,"第三方广告",data.adID)
            end
        end
    else
        local umengKey = public_inter_startup_click_times
        if umengType == "show" then
            umengKey = public_inter_startup_show_times
        end
        if data.adType == "default" then
            umengKey = public_inter_startup_default_click_times
            if umengType == "show" then
                umengKey = public_inter_startup_default_show_times
            end
        end

        DA.sendEventWithMap(umengKey,DA.getLanguageGroup(),DA.getLanguageType().."_"..data.adID)

        -- 黑名单展示写入
        NV.writeShowTime({
            key = "selfad_1_"..data.ident,
            updateTime = data.updateTime,
            showNum = data.showNum
        })
    end   
end



--加载开屏广告图片
function M:loadOpenRecommendImage(data)
    self:sendUmengStartUp(data,"show")

    if self._startScreennode then
        self._startScreennode:remove()
        self._startScreennode = nil
    end

    local path      = data.localImagePath
    local link      = data.appLink
    local appKey    = data.appKey
    local appName   = data.appName
    local openType  = data.openType
    local adID      = data.adID
    local adType    = data.adType
    local click_url = data.clickUrl
    local canClick  = true

    local node      = D.img(path):to(self)
    node.adType     = adType
    node:anchor(ccp(0.5,1))

    self._startScreennode = node
    -- 广告加下标
    local pos = ccp(540*X_FACTOR-10,70)
    self._adnode = nil
    -- if true then
    if BB_CHANNEL_ID == "A005" then
        self._adnode = D.imgsz("g/open/ad_en.png", CCSize(80*0.6*0.8,44*0.6*0.8)):p(pos):anchor(ccp(1,0)):to(self,100)
    elseif adType == "ad" or adType == "thirdad" then
        self._adnode = D.imgsz("g/open/ad.png", CCSize(80*0.6*0.8,44*0.6*0.8)):p(pos):anchor(ccp(1,0)):to(self,100)
    end
        
    -- 说明：
    -- 在Android环境下，框架对link字段有做特殊处理，当市场不需要启动直接下载时，则框架会置link字段为空，Android引擎就会直接根据appKey去打开本地市场
    -- 在link不为空时，
    if isandroid() then
        canClick = S.isNotEmpty(link) or S.isNotEmpty(appKey)
    else
        canClick = S.isNotEmpty(link)
        -- 儿童版不能点击
    if self:isPublishKids() then 
        canClick = false
    end
    end

    node:bindTouch()
    node.canTouch = true
    node.layer = self
    function node:onTouchBegan(x, y, touches)
        if not self.canTouch then return false end
    if canClick then
        return true
        else
        return false
        end
    end
    function node:onTouchEnded(x, y, touches)
        self.canTouch = false
        if adType == "ad" then
            -- public static final String DOWNLOAD     = "1";          // 下载
            -- public static final String URL          = "2";          // 打开网页
            -- public static final String VIDEO        = "3";          // 视频素材
            -- public static final String AUDIO        = "4";          // 音频素材
            -- public static final String SOURCECODE   = "5";          // H5源码
            if openType == "0" then
            elseif openType == "1" then
                self.layer:sendUmengStartUp(data,"click")
                if NV.isAppInstalled(appKey) or NV.existsApk(appKey) then
                    NV.openLink(link, true, appKey, appName,"1|ad|"..data.adID)
                else
                    if NT.isLocalWiFiAvailable() then
                        NV.openLink(link, true, appKey, appName,"1|ad|"..data.adID)
                    elseif NT.isInternetConnectionAvailable() then
                        NV.showVerify({
                            umengType = "开屏",
                            titleTag = 6,
                            callback = function(status)
                                if status == "1" then
                                    NV.openLink(link, true, appKey, appName,"1|ad|"..data.adID)
                                end
                            end
                        })
                    else
                        NV.showToast("网络不给力，请检查网络设置。")
                    end
                end
            elseif openType == "2" then
                self.layer:sendUmengStartUp(data,"click")
                if NT.isInternetConnectionAvailable() then
                    NV.addAdWebView(1)
                else
                    NV.showToast("网络不给力，请检查网络设置。")
                end
            elseif openType == "3" then
            elseif openType == "4" then
            elseif openType == "5" then
            end
        elseif NT.isLocalWiFiAvailable() then
            if adType == "thirdad" then
            elseif adType == "default" then
                local str = "1|默认图|"..data.adID
                self.layer:sendUmengStartUp(data,"click")
                if IsGoogle then
                    str = "900_开屏"
                end
                NV.openLink(link, true, appKey, appName, str)
            elseif adType == "selfad" then
                local str = "1|"
                data.adID = ifnil(data.adID,"0")
                if data.mediaType == "1" then
                    str = str.."独立开屏|"..data.adID
                elseif data.mediaType == "2" then
                    str = str.."通龄|"..data.adID
                    DA.sendCommonClickUMeng(data.adID,1)
                elseif data.mediaType == "3" then
                    local age = tonumber(data.mediaAge)
                    if age<2 then
                        age = "0-1岁"
                    elseif age > 5 then
                        age = "5+岁"
                    else
                        age = (age-1).."-"..age.."岁"
                    end
                    str = str..age.."|"..data.adID
                end
                self.layer:sendUmengStartUp(data,"click")
                if IsGoogle then
                    str = "900_开屏"
                end
                -- 打开链接
                NV.openLink(link, true, appKey, appName, str, openType)
            end
        end
    end
end

-- 加载版权信息
function M:loadCopyright()
    local scale = 1.0
    local pos = ccp(V.w / 2, 50 * Y_FACTOR)
    if not isLanscape() then
        pos = ccp(275 * X_FACTOR, 30)
        scale = 0.72
    end
    if DEVICE_MODEL == "x4" then
        scale = 2*scale
    end
   
    local label = U.loadLabelBMFont({
        text        = string.format(COMP_COPYRIGHT, os.date("%Y", os.time())),
        fontName    = "res/fnt/g/copyrightFont.fnt",
        color       = ccc3(0, 0, 0),
        pathAssign  = false,
    })

    label:p(pos):to(self,100000):scale(scale*0.38)


    local num = 0
    label:bindTouchHandled(function ()
        num = num + 1
        if num > 6 then
            BB_BOOL_SHOW_STATE_TOAST = true
        end
    end)

    if CHANNEL_PLATFORM == CHANNEL_PR_BUBUGAO then
        label:setOpacity(119)
        label:scale(scale*0.3)
    end

    self._copyright = label
end

-- 加载渠道
function M:loadChannel()
    if device.language ~= "zh" then
        return
    end 
    -- 根据不同渠道进行相应逻辑的加载
    local channelnode = nil
    if  CHANNEL_PLATFORM == CHANNEL_BASE then
        channelnode = D.img("g/pre_install/xxx.png"):to(self):p(960,0):anchor(ccp(1,0))
        return  
    end
    local imgName = nil
    if CHANNEL_PLATFORM == CHANNEL_360 then 
        -- 渠道: 360
        imgName = "g/channel/c_360.png"
    elseif CHANNEL_PLATFORM == CHANNEL_MI or CHANNEL_PLATFORM == CHANNEL_FB_MI then 
        -- 渠道: 小米
        -- 渠道: 小米[首发]
        imgName = "g/channel/c_mi.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_PPUC then 
        -- 渠道: ppuc首发
        imgName = "g/channel/c_tbuc.png"
    elseif CHANNEL_PLATFORM == CHANNEL_YYB or CHANNEL_PLATFORM == CHANNEL_FB_YYB then 
        -- 渠道: 应用宝
        imgName = "g/channel/c_yyb.png"
    elseif CHANNEL_PLATFORM == CHANNEL_BAIDU or CHANNEL_PLATFORM == CHANNEL_91 then 
        -- 渠道: 百度
        imgName = "g/channel/c_baidu.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_AND_91 then 
        -- 渠道: Android91联合首发
        imgName = "g/channel/cfb_un_and91.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_360 then
        -- 渠道: 360首发
        imgName = "g/channel/cfb_360.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_BAIDU_AND_91 then 
        -- 渠道: 百度+Android+91
        imgName = "g/channel/cfb_baidu_91_and.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_SOGO then
        -- 渠道: 搜狗
        imgName = "g/channel/cfb_sogo.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_HUAWEI then
        imgName = "g/channel/c_huawei.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_BABYHOME then
        imgName = "g/channel/c_babyhome.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_SAMSUNG then
        -- 三星首发
        imgName = "g/channel/cfb_samsung.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_BAIDU then
        imgName = "g/channel/cfb_baidu.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_UNION_360 then
        imgName = "g/channel/cfb_union_360.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_UNION_PP then
        imgName = "g/channel/cfb_union_pp.png"
    elseif CHANNEL_PLATFORM == CHANNEL_FB_LESHI then
        imgName = "g/channel/cfb_leshi.png"
    else
        -- 渠道: 默认
        -- Nothing to do..
    end
    if imgName then
    local radio = V.w/1080
    channelnode = D.imgsz(imgName, CCSize(206*radio,132*radio)):to(self,10)
    -- 竖屏适配
    if channelnode then
        if not isLanscape() then
            channelnode:p(270 * X_FACTOR, 100)
            if CHANNEL_PLATFORM == CHANNEL_FB_BABYHOME then
                channelnode:p(270 * X_FACTOR, 130)
            end
        else
            channelnode:anchor(ccp(1,0))
            channelnode:p(V.w, 0)
        end
    end
end
end









----------------------
-- 结点析构
----------------------
--[[--

视图析构，处理视图结点卸载、事件解除绑定等相关操作

]]
function M:onDestructor()
    -- [超类调用]
    M.super.onDestructor(self)
end








----------------------
-- 视频
----------------------
--[[--

获得视频路径

]]
function M:getVideoPath()
    if device.language == "zh" and not IsGoogle then 
        return IO.fullPath("res/mov/zh.mp4")
    else
        return IO.fullPath("res/mov/en.mp4")
    end
end









----------------------
-- 辅助方法
----------------------
-- 获得产品推荐图片
function M:getRecommendImage()
    if isempty(self.ADData) then
        self.ADData = NV.getADData(1)
    end
    return self.ADData
end

-- Add By SD.Mount 20151020
-- 判断wifi是否开启
function M:isWiFiAvailable()
  return true
end

-- 获得打开WIFI提示
function M:getOpenWifiTip()
    local result

    local lang = device.language
    if lang == "zh" then 
        result = "为了保护您的数据流量, 防止小孩误操作, 宝宝巴士关闭了您在非wifi环境下的页面访问。需要访问页面请打开您的Wifi"
    elseif lang == "zht" then 
        result = "爲了保護您的數據流量, 防止小孩誤操作, 寶寶巴士關閉了您在非wifi環境下的頁面訪問。需要訪問頁面請打開您的Wifi"
    elseif lang == "ja" then 
        result = "Wi-Fiをオンにしてください"
    elseif lang == "ko" then 
        result = "Wi-Fi 연결해주세요"
    elseif lang == "fr" then 
        result = "Merci d'activer votre connexion Wi-Fi"
    elseif lang == "ru" then 
        result = "Пожалуйста, включите Wi-Fi"
    elseif lang == "pt" then 
        result = "Não está ligado à rede Wi-Fi"
    elseif lang == "es" then 
        result = "Por favor active la conexión Wi-Fi"
    elseif lang == "ar" then 
        result = "Wi-Fi الرجاء الإتصال بال"
    else
        result = "Please turn on your Wi-Fi"
    end

    return result
end


function M:fullScreenAdaptation()

    local copyright = self._copyright
    local screenNode = self._startScreennode
    if tolua.isnull(screenNode) or screenNode.adType == "copyright" then
        return
    end
    local ch = 55 
    local lh = 84
    local screenH = 540*Y_FACTOR
    local ss = screenNode:getContentSize()
    local radio = V.w/ss.width

    local sh = ss.height*radio
    local whiteH = screenH-sh
    screenNode:anchor(ccp(0.5,1))
    if isLanscape() then
        local adY = 0
        if whiteH < ch then
            radio = screenH/ss.height
            screenNode:p(V.w/2,screenH)
            U.loadNodeMask({ 
                contentSize = CCSize(V.w, 30), 
                color       = COLOR3_WHITE,
            }):opacity(204):p(V.w/2,15):to(self,10)
            copyright:p(V.w/2,15)
            adY = 30+10
        elseif whiteH < (ch+lh) then
            screenNode:p(V.w/2,screenH)
            copyright:py((screenH-sh)/2)
            adY = screenH - ss.height*radio + 10
        else
            local imgName = "g/open/logo_en.png"
            if device.language == "zh" then
                imgName = "g/open/logo_zh.png"
            end
            self.logoTop = D.imgsz(imgName,CCSize(520/2,80/2)):anchor(ccp(0,0.5)):p(32,screenH-lh/2):to(self,10000)
            screenNode:p(V.w/2,screenH-lh)
            copyright:py((screenH-sh-lh)/2)
            adY = screenH-lh - ss.height*radio + 10
        end

        copyright:scale(copyright:getScale()*0.9)
        screenNode:scale(radio)

        if not tolua.isnull(self._adnode) then
            self._adnode:p(V.w-10,adY)
        end        
    else
        local contentsize = screenNode:getContentSize()
        screenNode:scale(760 / contentsize.width)
        screenNode:p(270 * X_FACTOR, 960 * Y_FACTOR)

        if V.fullSize.height/V.fullSize.width > 1.95 then
            local imgName = "g/open/logo_en.png"
            if device.language == "zh" then
                imgName = "g/open/logo_zh.png"
            end
            self.logoTop = D.imgsz(imgName,CCSize(520/2,80/2)):anchor(ccp(0,0.5)):p(32,V.fullSize.height-84/2):to(self,10000)
            screenNode:p(V.fullSize.width/2,V.fullSize.height-84)
        end
        copyright:py((screenNode:py()-contentsize.height*screenNode:getScale())/2)
    end

   
end


return M